<template>
  <el-breadcrumb :separator-icon="ArrowRight">
    <el-breadcrumb-item :to="{ path: '/' }">首页(登录)</el-breadcrumb-item>
    <el-breadcrumb-item>门诊</el-breadcrumb-item>
    <el-breadcrumb-item>门诊消费记录</el-breadcrumb-item>
  </el-breadcrumb>

  <div>
    <!-- 搜索与工具条 -->
    <el-card style="margin-top: 10px;">
      <el-form :inline="true" :model="search" class="demo-form-inline">
        <el-form-item label="选择日期">
          <el-date-picker
            v-model="search.dateRange"
            type="daterange"
            range-separator="~"
            start-placeholder="请选择日期"
            end-placeholder="请选择日期"
            value-format="YYYY-MM-DD"
            unlink-panels
            clearable
          />
        </el-form-item>
        <el-form-item label="科室">
          <el-select v-model="search.deptId" placeholder="请选择科室" style="width: 160px" clearable>
            <el-option v-for="d in deptOptions" :key="d.value" :label="d.label" :value="d.value" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-input v-model="search.keyword" placeholder="输入病人姓名/就诊卡号" clearable style="width: 240px;" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="">搜索</el-button>
          <el-button>重置</el-button>
        </el-form-item>
        <div style="flex: 1"></div>
        <el-form-item>
          <el-button type="success">导入</el-button>
          <el-button type="primary">导出</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 列表 -->
    <el-card style="margin-top: 10px;">
      <el-table :data="tableData" border style="width: 100%" v-loading="loading">
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column prop="operatingTime" label="操作时间" width="180" align="center">
          <template #default="{ row }">
            {{ row.operatingTime ? moment(row.operatingTime).format('YYYY-MM-DD HH:mm:ss') : '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="operatingNum" label="订单号" width="170" align="center" />
        <!-- <el-table-column prop="patientName" label="患者姓名" width="100" align="center" /> -->
        <!-- <el-table-column prop="cardNo" label="就诊卡号" width="140" align="center" /> -->
        <el-table-column prop="source" label="来源" width="120" align="center" />
        <el-table-column prop="businessName" label="业务类型" width="120" align="center" />
        <el-table-column prop="paymentMethod" label="支付方式" width="100" align="center" />
        <el-table-column prop="paymentAmount" label="支付金额" width="100" align="center" />
        <el-table-column prop="paymentStatus" label="缴费状态" width="100" align="center">
          <template #default="{ row }">
            <el-tag type="success" v-if="row.paymentStatus === '已缴费'">已缴费</el-tag>
            <el-tag type="info" v-else>未缴费</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="90" align="center">
          <template #default>
            <el-button type="primary" :icon="Calendar" circle />
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <div style="margin-top: 16px; text-align: right;">
        <el-pagination
          v-model:current-page="page.PageIndex"
          v-model:page-size="page.PageSize"
          :page-sizes="[2, 4, 6]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.totalCount"
          :background="true"
        />
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { onMounted, reactive, ref, watch } from 'vue'
import { ArrowRight, Calendar } from '@element-plus/icons-vue'
import moment from 'moment'
import { dataRead } from '@/Utils/Http'


interface PageState {
  PageIndex: number
  PageSize: number
    totalCount: number
    pageCount: number
}

const loading = ref(false)
const page = reactive<PageState>({ PageIndex: 1, PageSize: 2, totalCount: 0 ,    pageCount: 0,
})

const search = reactive({
  dateRange: [],
  deptId: undefined as number | undefined,
  keyword: ''
})

const deptOptions = ref([
  { label: '内科', value: 1 },
  { label: '外科', value: 2 },
  { label: '儿科', value: 3 }
])



const tableData = ref([])


watch(page, () => generateMock())

const generateMock = () => {
    dataRead.get('/BaseData/AmountQuery?BusinessId=1', { params: page })
   .then((res) => {
       tableData.value = res.data.data.data
       page.totalCount = res.data.data.totalCount
       page.pageCount = res.data.data.pageCount
   })
}

onMounted(() => {
  generateMock()
})

</script>

<style scoped>

</style>


